﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Operators Exercise 9</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Checks if given print is within the circle K( (1,1), 3) and out of the rectangle R(top=1, left=-1, width=6, height=2):</h1>
    <div>
        <label for="point-x">Point X:</label>
        <input type="number" id="point-x"/>
        <label for="point-y">Y:</label>
        <input type="number" id="point-y"/>
    </div>
    <button onclick="calculate()">Calculate</button>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        function calculate() {
            var circleX = 1;
            var circleY = 1;
            var radius = 3;
            var recX = -1;
            var recY = 1;
            var recWidth = 6;
            var recHeight = 2;
            var radius = 3;

            var pointX;
            var pointY;

            pointX = jsConsole.readFloat("#point-x");
            pointY = jsConsole.readFloat("#point-y");

            if (((((circleX - pointX) * (circleX - pointX)) + ((circleY - pointY) * (circleY - pointY))) < (radius * radius)) 
                && (((pointX - recX) > recWidth) || ((pointX - recX) < 0) || ((pointY - recY) > recHeight) || ((pointY - recY) < 0)))
            {
                jsConsole.writeLine("Point is inside the circle and outside the rectangle");
            }
            else
            {
                jsConsole.writeLine("Point is elsewhere");
            }
        }
    </script>
</body>
</html>